
import { getTableHeight } from "@/utils/table";
import { edit, changeStatus } from "@/utils/form";

import { dictionaryUpStatus, dictionaryRemove } from "@/api/dataDict";

// 表格组件 传参
export default {
  data() {
    return {

      dataGrid: {
        height: getTableHeight("allBtn", "dataGrid", this, 260),
        visible: false,
        loading: false,
        columns: [
          {
            label: "字典值",
            prop: "value",
            align: "center"
          },
          {
            label: "状态",
            prop: "statusName",
            align: "center"
          },
          {
            label: "排列顺序",
            prop: "showOrder",
            align: "center"
          },
          {
            label: "备注",
            prop: "remark",
            align: "center"
          },
          {
            width: "140",
            label: "操作",
            action: true,
            fixed: "right",
            align: "center"
          }
        ],
        data: [],
        pagination: {
          hidden: 2,
          pageNum: 1,
          pageSizes: [50, 100, 150],
          pageSize: 50,
          total: 0,
          pageCount: 0
        },
        btnList: [
          {
            label: "编辑",
            mthods: (row) => this.edit(row),
            type: "text"
          },
          {
            label: "启用",
            hide: (row) => row.status === 1,
            mthods: (row) => changeStatus(row, dictionaryUpStatus, "确定启用?", this.search, 0),
            type: "text"
          },
          {
            label: "禁用",
            hide: (row) => row.status === 0,
            mthods: (row) => changeStatus(row, dictionaryUpStatus, "确定禁用?", this.search, 1),
            type: "text",
            style: {
              color: "#F56C6C"
            }
          },
          {
            label: "删除",
            mthods: (row) => changeStatus(row, dictionaryRemove, "确定启用?", this.search),
            type: "text",
            style: {
              color: "#F56C6C"
            }
          }
        ]
      }
    };
  },
  methods: {
    edit(row) {
      this.editForm.options[2].attrs.disabled = true;
      edit("editForm", this, "", row);
    }

  }

};
